package com.ruoyi.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.domain.RecipeInfo;
import com.ruoyi.service.IRecipeInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * RecipeInfoController
 * 
 * @author ruoyi
 * @date 2025-01-11
 */
@RestController
@RequestMapping("/recipeInfo")
public class RecipeInfoController extends BaseController
{
    @Autowired
    private IRecipeInfoService recipeInfoService;

    /**
     * 查询RecipeInfo列表
     */
    @RequiresPermissions("recipeInfo:recipeInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(RecipeInfo recipeInfo)
    {
        startPage();
        List<RecipeInfo> list = recipeInfoService.selectRecipeInfoList(recipeInfo);
        return getDataTable(list);
    }

    /**
     * 导出RecipeInfo列表
     */
    @RequiresPermissions("recipeInfo:recipeInfo:export")
    @Log(title = "RecipeInfo", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RecipeInfo recipeInfo)
    {
        List<RecipeInfo> list = recipeInfoService.selectRecipeInfoList(recipeInfo);
        ExcelUtil<RecipeInfo> util = new ExcelUtil<RecipeInfo>(RecipeInfo.class);
        util.exportExcel(response, list, "RecipeInfo数据");
    }

    /**
     * 获取RecipeInfo详细信息
     */
    @RequiresPermissions("recipeInfo:recipeInfo:query")
    @GetMapping(value = "/{recipeId}")
    public AjaxResult getInfo(@PathVariable("recipeId") Long recipeId)
    {
        return success(recipeInfoService.selectRecipeInfoByRecipeId(recipeId));
    }

    /**
     * 新增RecipeInfo
     */
    @RequiresPermissions("recipeInfo:recipeInfo:add")
    @Log(title = "RecipeInfo", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RecipeInfo recipeInfo)
    {
        return toAjax(recipeInfoService.insertRecipeInfo(recipeInfo));
    }

    /**
     * 修改RecipeInfo
     */
    @RequiresPermissions("recipeInfo:recipeInfo:edit")
    @Log(title = "RecipeInfo", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RecipeInfo recipeInfo)
    {
        return toAjax(recipeInfoService.updateRecipeInfo(recipeInfo));
    }

    /**
     * 删除RecipeInfo
     */
    @RequiresPermissions("recipeInfo:recipeInfo:remove")
    @Log(title = "RecipeInfo", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recipeIds}")
    public AjaxResult remove(@PathVariable Long[] recipeIds)
    {
        return toAjax(recipeInfoService.deleteRecipeInfoByRecipeIds(recipeIds));
    }
}
